'''
requeste中可以通过Session发送请求，可以自动管理cookie。

'''
import requests
s= requests.Session()  #创建一个Session
print("登录之前的",s.cookies) #<RequestsCookieJar[]>为空
# 登录接口
url ="https://www.bagevent.com/user/login "
cs = {
    "access_type":"1",
    "loginType"	:"1",
    "emailLoginWay":"0",
    "account":"2780487875@qq.com",
    "password" : "qq2780487875",
    "remindmeBox":"on",
    "remindme" : "1"
}
r = s.post(url,data=cs) # 使用session发送请求
print(r.text)
print("登录之后的",s.cookies) # <RequestsCookieJar[<Cookie BAGSESSIONID=4caa4db0-84fb-420d-af82-12660ebba699 for .bagevent.com/>, <Cookie BAG_EVENT_CK_KEY_="2780487875@qq.com" for .bagevent.com/>, <Cookie BAG_EVENT_CK_TOKEN_=2440f5d17af838308ba4b390db81af38 for .bagevent.com/>, <Cookie BAG_EVENT_TOKEN_=02de735f68204d51009e7edda78e58c13a3fcdd1 for .bagevent.com/>, <Cookie JSESSIONID=D7C3ACC5D957968A754DD8BD104FCEB9 for www.bagevent.com/>]>

print("==============================================")



# dashborad接口
url = "https://www.bagevent.com/account/dashboard"
r= s.get(url)
# print(r.text)

url = "https://www.bagevent.com/user/login_out"
r = s.get(url)
print("退出之后的cookie:",s.cookies) # <RequestsCookieJar[<Cookie BAGSESSIONID=179f1e51-eadb-4f01-a9f3-2b6f5d79746c for .bagevent.com/>, <Cookie JSESSIONID=16A0A5EE2BFBFB47B56A1B6849EC0E35 for www.bagevent.com/>]>
